package com.rongchuan.wt.enums;

import com.rongchuan.wt.exception.EmployeeException;
import lombok.Getter;

@Getter
public enum RankEnum {
    //职级
    JUNIOR(1,"初级"),
    MIDDLE(2,"中级"),
    SENIOR(3,"高级");

    /**
     * 职级编码
     */
    private final int code;

    /**
     * 职级编码描述
     */
    private final String description;


   RankEnum(int code, String description) {
       this.code = code;
       this.description = description;
   }
   /**
    * 根据职级代码获取职级信息
    */
    public static RankEnum fromCode(int code) {
        for (RankEnum rankEnum : RankEnum.values()) {
            if (rankEnum.getCode() == code) {
                return rankEnum;
            }
        }
        throw new EmployeeException("不支持的等级类型: " + code);
    }
}
